#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main() {
	int n = 0;
	int m = 0;
	scanf("%d %d\n", &n, &m);
	int arr[2000] = { 0 };
	int tmp = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d ", &arr[i]);
	}
	for (int j = n; j < n + m; j++) {
		scanf("%d ", &arr[j]);
	}
	for (int i = 0; i < n + m; i++) {
		for (int j = 0; j < n + m - i - 1; j++) {
			if (arr[j] > arr[j + 1]) {
				int tmp = arr[j];
				arr[j] = arr[j + 1];
				arr[j + 1] = tmp;
			}
		}
	}
	for (int i = 0; i < n + m; i++) {
		printf("%d ", arr[i]);
	}
	return 0;
}